<!DOCTYPE html>
<html lang="zh">
  <head>
  <meta charset="UTF-8">
  <meta 
    name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
  <meta 
    http-equiv="X-UA-Compatible" 
    content="ie=edge">
  <meta 
    name="theme-color" 
    content="#fff" 
    id="theme-color">
  <meta 
    name="description" 
    content="愿你一生努力，一生被爱">
  <link 
    rel="icon" 
    href="/">
  <title>自动化监控核弹</title>
  
    
      <meta 
        property="og:title" 
        content="自动化监控核弹">
    
    
      <meta 
        property="og:url" 
        content="http://www.zsuuu.com/2023/11/14/%E8%87%AA%E5%8A%A8%E5%8C%96%E7%9B%91%E6%8E%A7%E6%A0%B8%E5%BC%B9/index.html">
    
    
      <meta 
        property="og:img" 
        content="./img/Machine.png">
    
    
      <meta 
        property="og:img" 
        content="愿你一生努力，一生被爱">
    
    
      <meta 
        property="og:type" 
        content="article">
      <meta 
        property="og:article:published_time" 
        content="2023-11-14">
      <meta 
        property="og:article:modified_time" 
        content="2023-11-14">
      <meta 
        property="og:article:author" 
        content="Ninos Hudson">
      
        
          <meta 
            property="og:article:tag" 
            content="screeps">
        
          <meta 
            property="og:article:tag" 
            content="python">
        
      
    
  
  
  <link rel="preload" href="//at.alicdn.com/t/font_1946621_i1kgafibvw.css" as="style" >
  <link rel="preload" href="//at.alicdn.com/t/font_1952792_89b4ac4k4up.css" as="style" >
  <link rel="preload" href="/css/main.css" as="style" >
  
  <link rel="modulepreload" href="//instant.page/5.1.0">
  
  <link rel="stylesheet" href="/css/main.css">
  
  <link rel="stylesheet" href="//at.alicdn.com/t/font_1946621_i1kgafibvw.css">
  
  <link rel="stylesheet" href="//at.alicdn.com/t/font_1952792_89b4ac4k4up.css">
  
  
  
    <link rel="stylesheet" href="/js/lib/lightbox/baguetteBox.min.css">
  
  <script>
    function loadScript(url, cb) {
      var script = document.createElement('script');
      script.src = url;
      if (cb) script.onload = cb;
      script.async = true;
      document.body.appendChild(script);
    }
    function loadCSS(href, data, attr) {
      var sheet = document.createElement('link');
      sheet.ref = 'stylesheet';
      sheet.href = href;
      sheet.dataset[data] = attr;
      document.head.appendChild(sheet);
    }
    function changeCSS(cssFile, data, attr) {
      var oldlink = document.querySelector(data);
      var newlink = document.createElement("link");
      newlink.setAttribute("rel", "stylesheet");
      newlink.setAttribute("href", cssFile);
      newlink.dataset.prism = attr;
      document.head.replaceChild(newlink, oldlink);
    }
  </script>
  
    
  
  <script>
    // control reverse button
    var reverseDarkList = {
      dark: 'light',
      light: 'dark'
    };
    var themeColor = {
      dark: '#1c1c1e',
      light: '#fff'
    }
    // get the data of css prefers-color-scheme
    var getCssMediaQuery = function() {
      return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
    };
    // reverse current darkmode setting function
    var reverseDarkModeSetting = function() {
      var setting = localStorage.getItem('user-color-scheme');
      if(reverseDarkList[setting]) {
        setting = reverseDarkList[setting];
      } else if(setting === null) {
        setting = reverseDarkList[getCssMediaQuery()];
      } else {
        return;
      }
      localStorage.setItem('user-color-scheme', setting);
      return setting;
    };
    // apply current darkmode setting
  </script>
  
    <script>
      var setDarkmode = function(mode) {
      var setting = mode || localStorage.getItem('user-color-scheme');
      if(setting === getCssMediaQuery()) {
        document.documentElement.removeAttribute('data-user-color-scheme');
        localStorage.removeItem('user-color-scheme');
        document.getElementById('theme-color').content = themeColor[setting];
        document.getElementById('theme-color').dataset.mode = setting;
      } else if(reverseDarkList[setting]) {
        document.documentElement.setAttribute('data-user-color-scheme', setting);
        document.getElementById('theme-color').content = themeColor[setting];
        document.getElementById('theme-color').dataset.mode = setting;
      } else {
        document.documentElement.removeAttribute('data-user-color-scheme');
        localStorage.removeItem('user-color-scheme');
        document.getElementById('theme-color').content = themeColor[getCssMediaQuery()];
        document.getElementById('theme-color').dataset.mode = getCssMediaQuery();
      }
    };
    setDarkmode();
    </script>
  
  
  
    <link rel="preload" href="/js/lib/lightbox/baguetteBox.min.js" as="script">
    <link rel="preload" href="/js/lib/lightbox/baguetteBox.min.css" as="style" >
  
  
    <link rel="preload" href="/js/lib/lozad.min.js" as="script">
  
  
  
  
  
  
<meta name="generator" content="Hexo 6.3.0"></head>

  <body>
    <div class="wrapper">
       
      <nav class="navbar">
  <div class="navbar-logo">
    <a class="navbar-logo-main" href="/">
      
      <span class="navbar-logo-dsc">知识全栈</span>
      </a>
  </div>
  <div class="navbar-menu">
    
      <a 
        href="/" 
        class="navbar-menu-item">
        
          首页
        
      </a>
    
      <a 
        href="/archives" 
        class="navbar-menu-item">
        
          归档
        
      </a>
    
      <a 
        href="/tags" 
        class="navbar-menu-item">
        
          标签
        
      </a>
    
      <a 
        href="/categories" 
        class="navbar-menu-item">
        
          分类
        
      </a>
    
    <button 
      class="navbar-menu-item darknavbar navbar-menu-btn" 
      aria-label="Toggle dark mode"
      id="dark">
      <i class="iconfont icon-weather"></i>
    </button>
    <button 
      class="navbar-menu-item searchnavbar navbar-menu-btn" 
      aria-label="Toggle search"
      id="search">
      <!-- <i 
        class="iconfont icon-search" 
        style="font-size: 1.2rem; font-weight: 400;">
      </i> -->
      <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img"
        class="iconify iconify--ion" width="28" height="28" preserveAspectRatio="xMidYMid meet" viewBox="0 0 512 512">
        <path fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="28"
          d="M256 80a176 176 0 1 0 176 176A176 176 0 0 0 256 80Z"></path>
        <path fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="28"
          d="M232 160a72 72 0 1 0 72 72a72 72 0 0 0-72-72Z"></path>
        <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="28"
          d="M283.64 283.64L336 336"></path>
      </svg>
    </button>
  </div>
</nav> 
      
      <div 
        id="local-search" 
        style="display: none">
        <input
          class="navbar-menu-item"
          id="search-input"
          placeholder="请输入搜索内容..." />
        <div id="search-content"></div>
      </div>
      
      <div class="section-wrap">
        <div class="container">
          <div class="columns">
            <aside class="left-column">
              
              <div class="card card-author">
                
  <img 
    src="./img/Machine.png" 
    class="author-img"
    width="88"
    height="88"
    alt="author avatar">

<p class="author-name">Ninos Hudson</p>
<p class="author-description">分享有趣的知识</p>
<div class="author-message">
  <a 
    class="author-posts-count" 
    href="/archives">
    <span>7</span>
    <span>文章</span>
  </a>
  <a 
    class="author-categories-count" 
    href="/categories">
    <span>3</span>
    <span>分类</span>
  </a>
  <a 
    class="author-tags-count" 
    href="/tags">
    <span>7</span>
    <span>标签</span>
  </a>
</div>

              </div>
               <div class="sticky-tablet">
  
  
    <article class="display-when-two-columns spacer">
      <div class="card card-content toc-card">
        <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0"><span class="toc-text">代码实现</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0%E8%BF%87%E7%A8%8B"><span class="toc-text">实现过程</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%B3%A8%E6%84%8F"><span class="toc-text">注意</span></a></li></ol>
      </div>
    </article>
  
  
  <article class="card card-content categories-widget">
    <div class="categories-card">
  <div class="categories-header">
    <i 
      class="iconfont icon-fenlei" 
      style="padding-right: 2px;">
    </i>分类
  </div>
  <div class="categories-list">
    
      <a href="/categories/%E5%AD%A6%E4%B9%A0/">
        <div class="categories-list-item">
          学习
          <span class="categories-list-item-badge">3</span>
        </div>
      </a>
    
      <a href="/categories/%E4%BB%A3%E7%A0%81/">
        <div class="categories-list-item">
          代码
          <span class="categories-list-item-badge">3</span>
        </div>
      </a>
    
      <a href="/categories/%E6%83%B3%E6%B3%95/">
        <div class="categories-list-item">
          想法
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
  </div>
</div>
  </article>
  
  <article class="card card-content tags-widget">
    <div class="tags-card">
  <div class="tags-header">
    <i 
      class="iconfont icon-biaoqian" 
      style="padding-right: 2px;">
    </i>热门标签
  </div>
  <div class="tags-list">
    
      <a 
        href="/tags/%E5%93%B2%E5%AD%A6/" 
        title="哲学">
        <div class="tags-list-item">哲学</div>
      </a>
    
      <a 
        href="/tags/blog/" 
        title="blog">
        <div class="tags-list-item">blog</div>
      </a>
    
      <a 
        href="/tags/%E6%84%9F%E6%A6%82/" 
        title="感概">
        <div class="tags-list-item">感概</div>
      </a>
    
      <a 
        href="/tags/%E5%8C%BA%E5%9D%97%E9%93%BE/" 
        title="区块链">
        <div class="tags-list-item">区块链</div>
      </a>
    
      <a 
        href="/tags/screeps/" 
        title="screeps">
        <div class="tags-list-item">screeps</div>
      </a>
    
      <a 
        href="/tags/python/" 
        title="python">
        <div class="tags-list-item">python</div>
      </a>
    
      <a 
        href="/tags/ProgressQuest/" 
        title="ProgressQuest">
        <div class="tags-list-item">ProgressQuest</div>
      </a>
    
  </div>
</div>
  </article>
  
  
</div>
            </aside>
            <main class="main-column">
              
<article class="card card-content">
  <header>
    <h1 class="post-title">
      自动化监控核弹
    </h1>
  </header>
  <div class="post-meta post-show-meta">
    <time datetime="2023-11-14T02:56:37.592Z">
      <i 
        class="iconfont icon-calendar" 
        style="margin-right: 2px;">
      </i>
      <span>2023-11-14</span>
    </time>
    
      <span class="dot"></span>
      
        <a 
          href="/categories/%E4%BB%A3%E7%A0%81/" 
          class="post-meta-link">
          代码
        </a>
      
    
    
      <span class="dot"></span>
      <span>899 字</span>
    
  </div>
  
    <div 
      class="post-meta post-show-meta" 
      style="margin-top: -10px;">
      <div style="display: flex; align-items: center;">
        <i 
          class="iconfont icon-biaoqian" 
          style="margin-right: 2px; font-size: 1.15rem;">
        </i>
        
          
          <a 
            href="/tags/screeps/" 
            class="post-meta-link">
            screeps
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/python/" 
            class="post-meta-link">
            python
          </a>
        
      </div>
    </div>
  
  </header>
  <div 
    id="section" 
    class="post-content">
    <h2 id="代码实现"><a href="#代码实现" class="headerlink" title="代码实现"></a>代码实现</h2><pre class="highlight"><span class="line">import screepsapi</span><br><span class="line">import time</span><br><span class="line">from PIL import Image, ImageDraw, ImageFont</span><br><span class="line">import datetime</span><br><span class="line"></span><br><span class="line">TOKEN = <span class="string">&quot;6a49ab20-1cf4-4b11-afe4-e7f8541529f6&quot;</span></span><br><span class="line">api = screepsapi.API(token=TOKEN)</span><br><span class="line">temp = <span class="string">&#x27;&#x27;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">def print_nuke(shard_name):</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;获取时间&quot;</span>)</span><br><span class="line">    game_time = api.time(shard_name)</span><br><span class="line">    time.sleep(5)</span><br><span class="line">    <span class="built_in">print</span>(game_time)</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;获取核弹数据&quot;</span>)</span><br><span class="line">    nuker = api.nukes()</span><br><span class="line">    time.sleep(5)</span><br><span class="line">    <span class="comment"># print(nuker)</span></span><br><span class="line">    <span class="comment"># print(nuker[&#x27;nukes&#x27;])</span></span><br><span class="line">    nukers = nuker[<span class="string">&#x27;nukes&#x27;</span>]</span><br><span class="line">    <span class="comment"># print(nukers[shard_name])</span></span><br><span class="line">    s0nukers = nukers[shard_name]</span><br><span class="line">    <span class="comment"># print(s0nukers[1][&#x27;room&#x27;])</span></span><br><span class="line">    global temp</span><br><span class="line">    temp += <span class="string">&quot;======================&quot;</span> + shard_name + <span class="string">&quot;======================&quot;</span> + <span class="string">&quot;\n&quot;</span></span><br><span class="line">    <span class="built_in">print</span>(shard_name)</span><br><span class="line">    <span class="keyword">for</span> mix <span class="keyword">in</span> s0nukers:</span><br><span class="line">        time.sleep(5)</span><br><span class="line">        try:</span><br><span class="line">            result = mix[<span class="string">&#x27;launchRoomName&#x27;</span>] + <span class="string">&quot; [ &quot;</span> + \</span><br><span class="line">                     api.room_overview(mix[<span class="string">&#x27;launchRoomName&#x27;</span>], shard=shard_name)[<span class="string">&#x27;owner&#x27;</span>][</span><br><span class="line">                         <span class="string">&#x27;username&#x27;</span>] + <span class="string">&quot; ] &quot;</span> + <span class="string">&quot;=&gt; &quot;</span> + mix[<span class="string">&#x27;room&#x27;</span>] + <span class="string">&quot; [ &quot;</span> + \</span><br><span class="line">                     api.room_overview(mix[<span class="string">&#x27;room&#x27;</span>], shard=shard_name)[<span class="string">&#x27;owner&#x27;</span>][<span class="string">&#x27;username&#x27;</span>] + <span class="string">&quot; ] &quot;</span> + <span class="string">&quot;: &quot;</span> + str(</span><br><span class="line">                mix[<span class="string">&#x27;landTime&#x27;</span>] - game_time)</span><br><span class="line">            <span class="comment"># print(result)</span></span><br><span class="line">            temp += result + <span class="string">&#x27;\n&#x27;</span></span><br><span class="line">        except:</span><br><span class="line">            result = mix[<span class="string">&#x27;launchRoomName&#x27;</span>] + <span class="string">&quot; [ &quot;</span> + \</span><br><span class="line">                     api.room_overview(mix[<span class="string">&#x27;launchRoomName&#x27;</span>], shard=shard_name)[<span class="string">&#x27;owner&#x27;</span>][</span><br><span class="line">                         <span class="string">&#x27;username&#x27;</span>] + <span class="string">&quot; ] &quot;</span> + <span class="string">&quot;=&gt; &quot;</span> + mix[<span class="string">&#x27;room&#x27;</span>] + <span class="string">&quot; [ ? ] &quot;</span> + <span class="string">&quot;: &quot;</span> + str(</span><br><span class="line">                mix[<span class="string">&#x27;landTime&#x27;</span>] - game_time)</span><br><span class="line">            <span class="comment"># print(result)</span></span><br><span class="line">            temp += result + <span class="string">&#x27;\n&#x27;</span></span><br><span class="line">    <span class="built_in">print</span>(temp)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">def print_nuke_new(shard_name):</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;获取&#123;&#125;时间&quot;</span>.format(shard_name))</span><br><span class="line">    game_time = api.time(shard_name)</span><br><span class="line">    time.sleep(5)</span><br><span class="line">    <span class="built_in">print</span>(game_time)</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;获取核弹数据&quot;</span>)</span><br><span class="line">    nuker = api.nukes()</span><br><span class="line">    time.sleep(5)</span><br><span class="line">    nukers = nuker[<span class="string">&#x27;nukes&#x27;</span>]</span><br><span class="line">    s0nukers = nukers[shard_name]</span><br><span class="line">    global temp</span><br><span class="line">    temp += <span class="string">&quot;======================&quot;</span> + shard_name + <span class="string">&quot;======================&quot;</span> + <span class="string">&quot;\n&quot;</span></span><br><span class="line">    <span class="built_in">print</span>(shard_name)</span><br><span class="line">    <span class="keyword">for</span> mix <span class="keyword">in</span> s0nukers:</span><br><span class="line">        time.sleep(5)</span><br><span class="line">        try:</span><br><span class="line">            launchRoomName = api.room_overview(mix[<span class="string">&#x27;launchRoomName&#x27;</span>], shard=shard_name)[<span class="string">&#x27;owner&#x27;</span>][<span class="string">&#x27;username&#x27;</span>]</span><br><span class="line">        except:</span><br><span class="line">            launchRoomName = <span class="string">&quot;?&quot;</span></span><br><span class="line">        time.sleep(5)</span><br><span class="line">        try:</span><br><span class="line">            room = api.room_overview(mix[<span class="string">&#x27;room&#x27;</span>], shard=shard_name)[<span class="string">&#x27;owner&#x27;</span>][<span class="string">&#x27;username&#x27;</span>]</span><br><span class="line">        except:</span><br><span class="line">            room = <span class="string">&quot;?&quot;</span></span><br><span class="line">        time.sleep(5)</span><br><span class="line">        result = (mix[<span class="string">&#x27;launchRoomName&#x27;</span>] + <span class="string">&quot; [ &quot;</span> + launchRoomName + <span class="string">&quot; ] &quot;</span> + <span class="string">&quot;=&gt; &quot;</span> +</span><br><span class="line">                  mix[<span class="string">&#x27;room&#x27;</span>] + <span class="string">&quot; [ &quot;</span> + room + <span class="string">&quot; ] &quot;</span> + <span class="string">&quot;: &quot;</span> +</span><br><span class="line">                  str(mix[<span class="string">&#x27;landTime&#x27;</span>] - game_time))</span><br><span class="line">        <span class="built_in">print</span>(result)</span><br><span class="line">        temp += result + <span class="string">&#x27;\n&#x27;</span></span><br><span class="line">    <span class="built_in">print</span>(temp)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">def runapp():</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;开始获取数据&quot;</span>)</span><br><span class="line">    print_nuke_new(<span class="string">&#x27;shard0&#x27;</span>)</span><br><span class="line">    time.sleep(5)</span><br><span class="line">    print_nuke_new(<span class="string">&#x27;shard1&#x27;</span>)</span><br><span class="line">    time.sleep(5)</span><br><span class="line">    print_nuke_new(<span class="string">&#x27;shard2&#x27;</span>)</span><br><span class="line">    time.sleep(5)</span><br><span class="line">    print_nuke_new(<span class="string">&#x27;shard3&#x27;</span>)</span><br><span class="line">    time.sleep(5)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">def save2(text_input):</span><br><span class="line">    newline_count = text_input.count(<span class="string">&quot;\n&quot;</span>)</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;字符串中换行符的次数：&quot;</span>, newline_count)</span><br><span class="line">    linepix = int(1024 * (newline_count + 4) / 32)</span><br><span class="line">    <span class="comment"># 创建一个空白图像</span></span><br><span class="line">    width, height = 1080, linepix</span><br><span class="line">    background_color = (47, 79, 79)</span><br><span class="line">    image = Image.new(<span class="string">&quot;RGB&quot;</span>, (width, height), background_color)</span><br><span class="line">    draw = ImageDraw.Draw(image)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 在图像上绘制文本</span></span><br><span class="line">    text = text_input</span><br><span class="line">    font_size = 30</span><br><span class="line">    font = ImageFont.truetype(<span class="string">&quot;Arial.ttf&quot;</span>, font_size)  <span class="comment"># 使用合适的字体文件路径</span></span><br><span class="line">    text_color = (192, 192, 192)</span><br><span class="line">    text_position = (50, 50)</span><br><span class="line">    draw.text(text_position, text, fill=text_color, font=font)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 保存图像</span></span><br><span class="line">    image.save(<span class="string">&quot;/www/wwwroot/pythonproject/nuker/nukers2.png&quot;</span>)</span><br><span class="line">    image.save(<span class="string">&quot;/www/wwwroot/nuker.com/nukers2.png&quot;</span>)</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;save png&quot;</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">def save(text_input):</span><br><span class="line">    newline_count = text_input.count(<span class="string">&quot;\n&quot;</span>)</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;字符串中换行符的次数：&quot;</span>, newline_count)</span><br><span class="line">    linepix = int(1024 * (newline_count + 4) / 32)</span><br><span class="line">    <span class="comment"># 创建一个空白图像</span></span><br><span class="line">    width, height = 1080, linepix</span><br><span class="line">    background_color = (47, 79, 79)</span><br><span class="line">    image = Image.new(<span class="string">&quot;RGB&quot;</span>, (width, height), background_color)</span><br><span class="line">    draw = ImageDraw.Draw(image)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 在图像上绘制文本</span></span><br><span class="line">    text = text_input</span><br><span class="line">    font_size = 30</span><br><span class="line">    font = ImageFont.truetype(<span class="string">&quot;Arial.ttf&quot;</span>, font_size)  <span class="comment"># 使用合适的字体文件路径</span></span><br><span class="line">    text_color = (192, 192, 192)</span><br><span class="line">    text_position = (50, 50)</span><br><span class="line">    draw.text(text_position, text, fill=text_color, font=font)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 保存图像</span></span><br><span class="line">    image.save(<span class="string">&quot;/www/wwwroot/pythonproject/nuker/nukers.png&quot;</span>)</span><br><span class="line">    image.save(<span class="string">&quot;/www/wwwroot/nuker.com/nukers.png&quot;</span>)</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;save png&quot;</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">def runmain():</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&#x27;爬爬脚本启动&#x27;</span>)</span><br><span class="line">    save2(<span class="string">&quot;loding...\nOK&quot;</span>)</span><br><span class="line">    start_time = time.time()</span><br><span class="line">    user = api.me()</span><br><span class="line">    time.sleep(5)</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;使用&quot;</span>, user[<span class="string">&#x27;username&#x27;</span>], <span class="string">&quot;的Key进行爬取&quot;</span>)</span><br><span class="line">    game_time_now = api.time(<span class="string">&#x27;shard3&#x27;</span>)</span><br><span class="line">    time.sleep(5)</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;当前S3游戏时间为&quot;</span>, game_time_now)</span><br><span class="line">    runapp()</span><br><span class="line">    end_time = time.time()</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&quot;本轮此请求请求耗时: &#123;:.2f&#125;秒&quot;</span>.format(end_time - start_time))</span><br><span class="line">    global temp</span><br><span class="line">    temp += <span class="string">&quot;$$<span class="variable">$takes</span> &#123;:.2f&#125; seconds$$$\n&quot;</span>.format(end_time - start_time)</span><br><span class="line">    current_time = datetime.datetime.now()</span><br><span class="line">    <span class="built_in">print</span>(current_time)</span><br><span class="line">    temp += <span class="string">&quot;$$$&quot;</span> + str(current_time) + <span class="string">&quot;$$$&quot;</span></span><br><span class="line">    save(temp)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&#x27;__main__&#x27;</span>:</span><br><span class="line">    try:</span><br><span class="line">        runmain()</span><br><span class="line">        <span class="built_in">print</span>(temp)</span><br><span class="line">    except:</span><br><span class="line">        <span class="built_in">print</span>(<span class="string">&quot;crush&quot;</span>)</span><br><span class="line"></span><br><span class="line"></span><br></pre>

<h2 id="实现过程"><a href="#实现过程" class="headerlink" title="实现过程"></a>实现过程</h2><p>安装ubantu系统服务器<br>安装宝塔面板<br>下载配置python3环境<br>上传代码<br>安装依赖，手动使用pip安装<br>编写自动执行任务</p>
<pre class="highlight"><span class="line">python3 /www/wwwroot/pythonproject/nuker/nukeroversee.py </span><br></pre>

<p>定时执行<br>制作网站</p>
<h2 id="注意"><a href="#注意" class="headerlink" title="注意"></a>注意</h2><p>在shell中使用python代码控制服务器需要使用完整路径</p>
<pre class="highlight"><span class="line">image.save(<span class="string">&quot;/www/wwwroot/pythonproject/nuker/nukers.png&quot;</span>)</span><br></pre>
  </div>
  <div>
    
  </div>
</article>
<div class="nav">
  
    <div class="nav-item-prev">
      <a 
        href="/2023/12/18/ProgressQuest%E9%A1%B9%E7%9B%AE/" 
        class="nav-link">
        <i class="iconfont icon-left nav-prev-icon"></i>
        <div>
          <div class="nav-label">上一篇</div>
          
            <div class="nav-title">ProgressQuest项目 </div>
          
        </div>
      </a>
    </div>
  
  
    <div class="nav-item-next">
      <a 
        href="/2023/03/10/serverless%E4%B9%8Bblog%E6%8B%AF%E6%95%91%E8%A1%8C%E5%8A%A8/" 
        class="nav-link">
        <div>
          <div class="nav-label">下一篇</div>
          
            <div class="nav-title">serverless之blog拯救行动 </div>
          
        </div>
        <i class="iconfont icon-right nav-next-icon"></i>
      </a>
    </div>
  
</div>

<div 
  class="card card-content toc-card" 
  id="mobiletoc">
  <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0"><span class="toc-text">代码实现</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0%E8%BF%87%E7%A8%8B"><span class="toc-text">实现过程</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%B3%A8%E6%84%8F"><span class="toc-text">注意</span></a></li></ol>
</div>
            </main>
            <aside class="right-column">
              <div class="sticky-widescreen">
  
  
    <article class="card card-content toc-card">
      <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0"><span class="toc-text">代码实现</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0%E8%BF%87%E7%A8%8B"><span class="toc-text">实现过程</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%B3%A8%E6%84%8F"><span class="toc-text">注意</span></a></li></ol>
    </article>
  
  
  <article class="card card-content">
    <div class="recent-posts-card">
  <div class="recent-posts-header">
    <i 
      class="iconfont icon-wenzhang_huaban" 
      style="padding-right: 2px;">
    </i>最近文章
  </div>
  <div class="recent-posts-list">
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2023-12-18</div>
        <a href="/2023/12/18/ProgressQuest%E9%A1%B9%E7%9B%AE/"><div class="recent-posts-item-content">ProgressQuest项目</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2023-11-14</div>
        <a href="/2023/11/14/%E8%87%AA%E5%8A%A8%E5%8C%96%E7%9B%91%E6%8E%A7%E6%A0%B8%E5%BC%B9/"><div class="recent-posts-item-content">自动化监控核弹</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2023-03-10</div>
        <a href="/2023/03/10/serverless%E4%B9%8Bblog%E6%8B%AF%E6%95%91%E8%A1%8C%E5%8A%A8/"><div class="recent-posts-item-content">serverless之blog拯救行动</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2023-03-10</div>
        <a href="/2023/03/10/%E3%80%8A%E6%8E%A7%E5%88%B6%E7%A4%BE%E4%BC%9A%E5%90%8E%E8%AE%B0%E3%80%8B%E5%90%89%E5%B0%94%C2%B7%E5%BE%B7%E5%8B%92%E5%85%B9/"><div class="recent-posts-item-content">《控制社会后记》</div></a>
      </div>
    
  </div>
</div>
  </article>
  
  
</div>
            </aside>
          </div>
        </div>
      </div>
    </div>
     
    <footer class="footer">
  <div class="footer-container">
    <div>
      <div class="footer-dsc">
        <span>
          Copyright ©
          
            1993
          
          
                - 
                2023
          
        </span>
        &nbsp;
        <a 
          href="/" 
          class="footer-link">
          知识全栈
        </a>
      </div>
    </div>

    
    
    
    
</footer>
 
    
  <a 
    role="button" 
    id="scrollbutton" 
    class="basebutton" 
    aria-label="回到顶部">
    <i class="iconfont icon-arrowleft button-icon"></i>
  </a>

<a 
  role="button" 
  id="menubutton"
  aria-label="menu button"
  class="basebutton">
  <i class="iconfont icon-menu button-icon"></i>
</a>
<a 
  role="button" 
  id="popbutton" 
  class="basebutton" 
  aria-label="控制中心">
  <i class="iconfont icon-expand button-icon"></i>
</a>
<a 
  role="button" 
  id="darkbutton" 
  class="basebutton darkwidget" 
  aria-label="夜色模式">
  <i class="iconfont icon-weather button-icon"></i>
</a>
<a 
  role="button" 
  id="searchbutton" 
  class="basebutton searchwidget" 
  aria-label="搜索">
  <i class="iconfont icon-search button-icon"></i>
</a> 
     
     
     
      <script>
  var addImgLayout = function () {
    var img = document.querySelectorAll('.post-content img')
    var i
    for (i = 0; i < img.length; i++) {
      var wrapper = document.createElement('a')
      wrapper.setAttribute('href', img[i].getAttribute('data-src'))
      wrapper.setAttribute('aria-label', 'illustration')
      wrapper.style.cssText =
        'width: 100%; display: flex; justify-content: center;'
      if (img[i].alt) wrapper.dataset.caption = img[i].alt
      wrapper.dataset.nolink = true
      img[i].before(wrapper)
      wrapper.append(img[i])
      var divWrap = document.createElement('div')
      divWrap.classList.add('gallery')
      wrapper.before(divWrap)
      divWrap.append(wrapper)
    }
    baguetteBox.run('.gallery')
  }
</script>
<script>
  loadScript(
    "/js/lib/lightbox/baguetteBox.min.js",
    addImgLayout
  )
</script>
 
     
     
    <script src="/js/main.js"></script> 
     
    
      <script>
        var addLazyload = function () {
          var observer = lozad('.lozad', {
            load: function (el) {
              el.srcset = el.getAttribute('data-src')
            },
            loaded: function (el) {
              el.classList.add('loaded')
            },
          })
          observer.observe()
        }
      </script>
      <script>
        loadScript('/js/lib/lozad.min.js', addLazyload)
      </script>
    
    <script src="//instant.page/5.1.0" type="module"
      integrity="sha384-by67kQnR+pyfy8yWP4kPO12fHKRLHZPfEsiSXR8u2IKcTdxD805MGUXBzVPnkLHw"></script>
    
    
      <script>
        setTimeout(() => {localSearch("search.json")}, 0)
      </script>
    
  </body>
</html>
